package com.mxpio.erp.common.workshop.entity;

import java.math.BigDecimal;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mxpio.erp.common.jpa.model.Notice;
import com.mxpio.erp.common.jpa.model.NoticeLine;
import com.mxpio.erp.common.technology.entity.WorkShop;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;

import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_WORKSHOP_PICKING_NOTICE")
@Schema(description="生产领料通知单")
public class MoPickingNotice extends Notice {

	private static final long serialVersionUID = 1L;

	//生产订单相关字段
	@Column(name = "PRODUCT_ITEM_CODE_")
	@Schema(description = "产品编号")
	private String productItemCode;
	@Column(name = "PRODUCT_ITEM_NAME_")
	@Schema(description = "产品名称")
	private String productItemName;
	@Column(name = "ORDER_QANTITY_")
	@Schema(description = "订单数量")
	private BigDecimal orderQuantity;
	@Column(name = "PRODUCT_DRAWING_NO_")
	@Schema(description = "图号")
	private String productDrawingNo;
	@Column(name = "MAIN_WORKSHOP_")
	@Schema(description = "主制车间")
	@Dict(dicCode = "workShopCode",dicEntity = WorkShop.class,dicText = "workShopName")
	private String mainWorkshop;


	@Transient
	private List<MoPickingNoticeLine> moPickingNoticeLines;

	@Transient
	private ManufactureOrder order;//业务单据
	@Override
	public String initTypeCode() {
		return "NP1";
	}

	@Override
	public NoticeLine createLine(OrderExcuteLineVo orderExcuteVo) {
		MoPickingNoticeLine noticeLine = new MoPickingNoticeLine();
		noticeLine.setOriginBizLineNo(orderExcuteVo.getBizOrderlineNo());
		noticeLine.setOriginBizNo(orderExcuteVo.getBizOrderNo());
		noticeLine.setItemCode(orderExcuteVo.getItemCode());
		noticeLine.setNoticeNo(this.getNoticeNo());
		noticeLine.setQuantity(orderExcuteVo.getQuantity());
		noticeLine.setSort(orderExcuteVo.getSort());
		noticeLine.setLotNo(orderExcuteVo.getLotNo());
		noticeLine.setSubLotIndex(orderExcuteVo.getSubLotIndex());
		noticeLine.setSupplementReason(orderExcuteVo.getSupplementReason());//处理补料原因字段
		return noticeLine;
	}

	@Override
	public List<? extends NoticeLine> getNoticeLines() {
		return this.moPickingNoticeLines;
	}

}
